//
//  XVCProductDetailShow.m
//  ppkc2016
//
//  Created by 拼凑的断音 on 16/3/31.
//  Copyright © 2016年 拼凑的断音. All rights reserved.
//

#import "XVCProductDetailShow.h"
#import "XXTool.h"

#import "ShowTipAndContentClickCell.h"
#import "ViewBusinessPosterButton.h"
#import "XTCReleasePersonInfomation.h"
#import "XTCProductDetailImgShow.h"
#import "XVCAppointMentExhibitor.h"
#import "XVCVisitorAppointmentDetail.h"
#import "LiuyanViewController.h"

#import <MessageUI/MessageUI.h>

@interface XVCProductDetailShow ()<UITableViewDelegate,UITableViewDataSource,UIActionSheetDelegate,MFMailComposeViewControllerDelegate,XTCReleasePersonInfomationDelegate>

@property (nonatomic,strong) UITableView* tableview;

//@property (nonatomic,strong) ViewBusinessPosterButton *posterButton;

@property (nonatomic,strong) UIBarButtonItem *barRightButton;
@property (nonatomic,strong) UIButton *testButton;

@property(nonatomic,strong) UIView *bottomView;

@property(nonatomic) UIButton* postButton;

@property(nonatomic) UIButton* liuyan;

@property(nonatomic)UIView* line;

@end

@implementation XVCProductDetailShow
{
    NSMutableArray <XMLNameAndValueModel*> *exInfoArray;
    NSMutableArray <XMLNameAndValueModel*> *productInfoArray;
    XMLRealsePersonInformation *useData;
    NSString *callNumber;
    NSString *emailSend;
    NSString* orderId;
}

#pragma mark getter
-(UITableView*)tableview
{
    if (_tableview==nil)
    {
        _tableview = [[UITableView alloc] init];
        _tableview.delegate = self;
        _tableview.dataSource = self;
        _tableview.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        _tableview.separatorColor = [XXTool colorWithLine];
        [self.view addSubview:_tableview];
    }
    return _tableview;
}

-(UIView*)bottomView{
    if(_bottomView== nil){
        _bottomView=[[UIView alloc]init];
        _bottomView.backgroundColor=[XXTool colorWithProject];
        
        _postButton=[[UIButton alloc]init];
        _postButton.titleLabel.font = [XXTool systemFontOfSize:16.5f];
        _postButton.backgroundColor=[UIColor clearColor];
        [_postButton setTitle:NSLocalizedString(@"查看海报", nil) forState:UIControlStateNormal];
        [_postButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_postButton addTarget:self action:@selector(clickPosterButton) forControlEvents:UIControlEventTouchDown];
        [_bottomView addSubview:_postButton];
        
        _line=[[UIView alloc]init];
        _line.backgroundColor=[UIColor whiteColor];
        [_bottomView addSubview:_line];
        
        _liuyan=[[UIButton alloc]init];
        _liuyan.titleLabel.font = [XXTool systemFontOfSize:16.5f];
        _liuyan.backgroundColor=[UIColor clearColor];
        [_liuyan setTitle:NSLocalizedString(@"留言", nil) forState:UIControlStateNormal];
        [_liuyan setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_liuyan addTarget:self action:@selector(clickLiuyanButton) forControlEvents:UIControlEventTouchDown];
        [_bottomView addSubview:_liuyan];
        
        [self.view addSubview:_bottomView];
    }
    return _bottomView;
}

//-(ViewBusinessPosterButton*)posterButton
//{
//    if (_posterButton==nil)
//    {
//        _posterButton = [[ViewBusinessPosterButton alloc] init];
//        [_posterButton addTarget:self Select:@selector(clickPosterButton) ForEvent:DKButtonEventPressedEnd];
//        [self.view addSubview:_posterButton];
//    }
//    return _posterButton;
//}

-(UIBarButtonItem*)barRightButton
{
    if (_barRightButton==nil)
    {
        _testButton=[[UIButton alloc] init];
        [_testButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_testButton addTarget:self action:@selector(clickCancelAppointment) forControlEvents:UIControlEventTouchUpInside];
        
        _barRightButton = [[UIBarButtonItem alloc] initWithCustomView:_testButton];
    }
    return _barRightButton;
}

-(void)initParameter
{
    
}

-(void)getData
{
    [self.view startLoading];
    _testButton.frame=CGRectMake(0, 0, 80, 50);
    [XMLRealsePersonInformation requestRleaseInformationDetailWithGood_Id:self.goodID
                                                               completion:^(BOOL isSuccess, XMLRealsePersonInformation *model) {
                                                                   if (isSuccess)
                                                                   {
                                                                       productInfoArray = [[NSMutableArray alloc] init];
                                                                       useData = model;
                                                                       
                                                                       exInfoArray = [model.zslist mutableCopy];
                                                                       
                                                                       if ([useData.collection isEqualToString:@"0"]) //未收藏
                                                                       {
                                                                           [_testButton setTitle:NSLocalizedString(@"收藏展品", nil ) forState:UIControlStateNormal];
//                                                                            _testButton.frame=CGRectMake(0, 0, 90, 50);
//                                                                           _barRightButton.title = NSLocalizedString(@"收藏展品", nil);
                                                                       }
                                                                       else
                                                                       {
                                                                           
                                                                           [_testButton setTitle:NSLocalizedString(@"已收藏", nil ) forState:UIControlStateNormal];
//                                                                           _testButton.frame=CGRectMake(0, 0, 80, 50);
//                                                                           _barRightButton.title = NSLocalizedString(@"已收藏", nil);
                                                                       }
                                                                      
                                                                       
                                                                       for (NSInteger i=exInfoArray.count-1
                                                                            ; i>=0; i--)
                                                                       {
                                                                           XMLNameAndValueModel *temp =  exInfoArray[i];
                                                                           if ([temp.value isEqualToString:@""])
                                                                           {
                                                                               [exInfoArray removeObjectAtIndex:i];
                                                                           }
                                                                       }
                                                                       //产品索引替换
                                                                       for (XMLNameAndValueModel *temp in exInfoArray)
                                                                       {
                                                                           if ([temp.name isEqualToString:NSLocalizedString(@"产品索引", nil)])
                                                                           {
                                                                               NSString *indexShow = @"";
                                                                               NSArray *exIndexArray = [temp.value componentsSeparatedByString:@","];
                                                                               for (NSString *temp in exIndexArray)
                                                                               {
                                                                                   RLMResults *indexText = [RXMLExhibitorIndexModel objectsInRealm:[RLMRealm realmWithPath:[XXTool dataBasePath]] where:[NSString stringWithFormat:@"index_NO = '%@'",temp]];
                                                                                   if (indexText.count>0)
                                                                                   {
                                                                                       RXMLExhibitorIndexModel *indexModel = indexText[0];
                                                                                       if ([XXTool didCurrentLanguageChinese])
                                                                                       {
                                                                                           indexShow = [NSString stringWithFormat:@"%@\r%@",indexShow,indexModel.index_name_cn];
                                                                                       }
                                                                                       else
                                                                                       {
                                                                                           indexShow = [NSString stringWithFormat:@"%@\r%@",indexShow,indexModel.index_name_en];
                                                                                       }
                                                                                       
                                                                                   }
                                                                               }
                                                                               //去除多余/r
                                                                               if (indexShow.length>2)
                                                                               {
                                                                                   indexShow = [indexShow substringFromIndex:1];
                                                                               }
                                                                               
                                                                               temp.value = indexShow;
                                                                           }
                                                                       }
                                                                       
                                                                       if (useData.goods_name!=nil&&![useData.goods_name isEqual:[NSNull null]])
                                                                       {
                                                                           XMLNameAndValueModel *temp1 = [[XMLNameAndValueModel alloc] init];
                                                                           temp1.name = NSLocalizedString(@"产品名称", nil);
                                                                           temp1.value = useData.goods_name;
                                                                           [productInfoArray addObject:temp1];
                                                                       }
                                                                       
                                                                       if (useData.goods_desc!=nil&&![useData.goods_desc isEqual:[NSNull null]])
                                                                                                      {
                                                                                                          XMLNameAndValueModel *temp2 = [[XMLNameAndValueModel alloc] init];
                                                                                                          temp2.name = NSLocalizedString(@"产品简介", nil);
                                                                                                          temp2.value = useData.goods_desc;
                                                                                                          [productInfoArray addObject:temp2];
                                                                     }
                                                                       
                                                                       [_tableview reloadData];
                                                                       [self refreshLayout];
                                                                   }
                                                                   [self.view stopLoading];
                                                               }];
   
}

-(void)initUI
{
    [self.navigationItem setTitle:NSLocalizedString(@"展品详情", nil)];
    
    [self.navigationItem setRightBarButtonItem:self.barRightButton];
    
    [self tableview];
    
    [self bottomView];
    
    NSLog(@"initUI");
    
   // [self posterButton];
    
    
}


-(void)refreshLayout:(CGRect)frame
{
    NSLog(@"refreshLayout");
    
    if(UserInfo.shareUserInfo.isExhibitor){
        _liuyan.hidden=YES;
        _line.hidden=YES; 
    }
    
    if ([useData.zs_hburltype intValue]==0)
    {
        _postButton.hidden = YES;
        _tableview.frame = CGRectMake(0, 0, frame.size.width
                                      , frame.size.height-45);
        
        _liuyan.frame=CGRectMake(0, 0, _bottomView.frame.size.width, _bottomView.frame.size.height);
        
    }
    else
    {
        _postButton.hidden = NO;
        _tableview.frame = CGRectMake(0, 0, frame.size.width
                                      , frame.size.height-45);
        
        _line.frame=CGRectMake(_bottomView.frame.size.width/2-1, 1, 2, _bottomView.frame.size.height-2);
        _liuyan.frame=CGRectMake(0, 0, _bottomView.frame.size.width/2, _bottomView.frame.size.height);
        if(_liuyan.hidden==YES){
            _postButton.frame=CGRectMake(0, 0, _bottomView.frame.size.width, _bottomView.frame.size.height);
        }else{
            _postButton.frame=CGRectMake(_bottomView.frame.size.width/2, 0, _bottomView.frame.size.width/2, _bottomView.frame.size.height);
        }
    }
    _bottomView.frame = CGRectMake(0
                                   , _tableview.frame.size.height+_tableview.frame.origin.y
                                   , frame.size.width
                                   , 45);
    if(_liuyan.hidden == YES && _postButton.hidden == YES){
        _bottomView.hidden=YES;
        _tableview.frame = CGRectMake(0, 0, frame.size.width
                                      , frame.size.height);
    }
    
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    NSLog(@"getData");
    [self getData];
}

#pragma mark tableveiwDatasource
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0)
    {
        if (indexPath.row==0)
        {
            XTCProductDetailImgShow *cell = [XTCProductDetailImgShow cellSelectionStyleNoneWithTableView:tableView];
            [cell setcellWithData:useData.list];
            return cell;
        }
        else
        {
            ShowTipAndContentClickCell *cell = [ShowTipAndContentClickCell cellWithTableView:tableView];
            [cell setCellWithData:productInfoArray[indexPath.row-1]];
            return cell;
        }
    }
    else
    {
        if (indexPath.section==1)
        {
            XTCReleasePersonInfomation *cell = [XTCReleasePersonInfomation cellSelectionStyleNoneWithTableView:tableView];
            cell.delegate = self;
            [cell setCellWithReleasePersonModel:useData personType:XVVReleasePersonInfomationExhibitor];
            [cell setCellButtonWithAppointmentStatus:useData.appointment collectStatus:useData.collection_exhibitor];
            return cell;
        }
        else
        {
            ShowTipAndContentClickCell *cell = [ShowTipAndContentClickCell cellWithTableView:tableView];
            [cell setCellWithData:exInfoArray[indexPath.row]];
            return cell;
        }
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0)
    {
        if (indexPath.row==0)
        {
            return [XTCProductDetailImgShow getCellHight];
        }
        else
        {
            return [ShowTipAndContentClickCell getCellHeightWithData:productInfoArray[indexPath.row-1]];
        }
    }
    else
    {
        if (indexPath.section==1)
        {
            return [XTCReleasePersonInfomation getHeightWithReleasePersonModel:useData personType:XVVReleasePersonInfomationExhibitor];
        }
        else
        {
            return [ShowTipAndContentClickCell getCellHeightWithData:exInfoArray[indexPath.row]];
        }
    }
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==0)
    {
        return productInfoArray.count+1;
    }
    else
    {
        if (section==1)
        {
            return 1;
        }
        return exInfoArray.count;
    }
}

#pragma mark tableviewdelegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if ([useData.vname isEqualToString:@""]||useData.vname==nil)
    {
//        if (indexPath.section==1)
//        {
//            XMLNameAndValueModel *temp = exInfoArray[indexPath.row];
//            if ([temp.name isEqualToString:NSLocalizedString(@"电话", nil)])
//            {
//                callNumber = temp.value;
//                UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:nil
//                                                                delegate:self
//                                                       cancelButtonTitle:NSLocalizedString(@"取消",nil)
//                                                  destructiveButtonTitle:[NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"拨打", nil),callNumber]
//                                                       otherButtonTitles:nil, nil];
//                [as showInView:self.view];
//            }
//            else if ([temp.name isEqualToString:NSLocalizedString(@"展位号", nil)])
//            {
//                
//            }
//            else if ([temp.name isEqualToString:NSLocalizedString(@"网址", nil)])
//            {
//                [WebController pushWebControllerWithSourceVC:self requestString:temp.value];
//            }
//            else if ([temp.name isEqualToString:NSLocalizedString(@"邮箱", nil)])
//            {
//                emailSend = temp.value;
//                UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:nil
//                                                                delegate:self
//                                                       cancelButtonTitle:NSLocalizedString(@"取消",nil)
//                                                  destructiveButtonTitle:[NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"邮箱", nil),emailSend]
//                                                       otherButtonTitles:nil, nil];
//                as.tag = 20;
//                [as showInView:self.view];
//            }
//        }
    }
    else
        if (indexPath.section==2)
    {
        XMLNameAndValueModel *temp = exInfoArray[indexPath.row];
        if ([temp.name isEqualToString:NSLocalizedString(@"电话", nil)])
        {
            callNumber = temp.value;
            UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:nil
                                                            delegate:self
                                                   cancelButtonTitle:NSLocalizedString(@"取消",nil)
                                              destructiveButtonTitle:[NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"拨打", nil),callNumber]
                                                   otherButtonTitles:nil, nil];
            as.tag = 10;
            [as showInView:self.view];
        }
        else if ([temp.name isEqualToString:NSLocalizedString(@"展位号", nil)])
        {
            
        }
        else if ([temp.name isEqualToString:NSLocalizedString(@"网址", nil)])
        {
            [WebController pushWebControllerWithSourceVC:self requestString:temp.value mapTitle:nil];
        }
        else if ([temp.name isEqualToString:NSLocalizedString(@"邮箱", nil)])
        {
            emailSend = temp.value;
            
            UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:nil
                                                            delegate:self
                                                   cancelButtonTitle:NSLocalizedString(@"取消",nil)
                                              destructiveButtonTitle:[NSString stringWithFormat:@"%@:%@",NSLocalizedString(@"邮箱", nil),emailSend]
                                                   otherButtonTitles:nil, nil];
            as.tag = 20;
            [as showInView:self.view];
        }
    }
}

#pragma mark actionsheetdelegate
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (actionSheet.tag==10) //电话
    {
        if(buttonIndex==0)
        {
            callNumber = [callNumber stringByReplacingOccurrencesOfString:@" " withString:@""];
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",callNumber]]];
        }
    }
    if (actionSheet.tag==20) //邮件
    {
        if (buttonIndex==0)
        {
            if ([MFMailComposeViewController canSendMail]) // 用户已设置邮件账户
            {
                [self sendEmailAction]; // 调用发送邮件的代码
            }
            else
            {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@",emailSend]]];
            }
        }
    }
}

#pragma mark XTCReleasePersonInfomationDelegate
-(void)releasePersonInfomationDidClickAppointmentButtonWithButton:(DKButton *)bespeak
{
    if ([bespeak.text isEqualToString:NSLocalizedString(@"已预约", nil)])
    {
        [XVCVisitorAppointmentDetail pushVistorAppointmentDetailWithSourceVC:self apmentID:useData.orderid];
    }
    else if ([bespeak.text isEqualToString:NSLocalizedString(@"预约", nil)])
    {
        [XVCAppointMentExhibitor pushAppointMentExhibitorWithSourceVC:self exhibitorId:useData.exhibitorid];
    }
}

-(void)releasePersonInfomationDidClickCollectButtonWithButton:(DKButton *)collect
{
    NSString *type = @"";
    if ([useData.collection_exhibitor intValue]==1) //已收藏
    {
        type = @"2";
    }
    else if ([useData.collection_exhibitor intValue]==0) //未收藏
    {
        type = @"1";
    }
    [SVProgressHUD show];
    [DKHTTPRequest sendDataWithShortUrl:@"favorites_visitor_co_exhibitor"
                                  Param:[XXTool formatStringWithLanguage:[NSString stringWithFormat:@"userid=%@&passwd=%@&exhibitorid=%@&type=%@",[UserInfo shareUserInfo].userID,[UserInfo shareUserInfo].userPassword,useData.exhibitorid,type]]
                             ImageArray:nil
                                TimeOut:10
                             Completion:^BOOL(NSMutableDictionary *serverDic, DKHTTPResponseType bufferType) {
                                 if ([[serverDic objectForKey:@"code"] intValue]==200)
                                 {
                                     if ([type isEqualToString:@"2"])
                                     {
                                         collect.image = [UIImage imageNamed:@"收藏按钮_未点击"];
                                         collect.text = NSLocalizedString(@"收藏", nil);
                                         useData.collection_exhibitor = @"0";
                                     }
                                     else if ([type isEqualToString:@"1"])
                                     {
                                         collect.image = [UIImage imageNamed:@"收藏按钮_已点击"];
                                         collect.text = NSLocalizedString(@"已收藏", nil);
                                         useData.collection_exhibitor = @"1";
                                     }
                                     [SVProgressHUD showSuccessWithStatus:NSLocalizedString(@"操作成功", nil)];
                                 }
                                 return YES;
                             } IsBuffering:NO
                      IsNeedReplaceWrap:NO
                        IsUseUpLoadHead:NO];
}

#pragma mark clickRightBarButton
-(void)clickCancelAppointment
{
    NSString *type = @"";
    if ([useData.collection intValue]==1) //已收藏
    {
        type = @"2";
    }
    else if ([useData.collection intValue]==0) //未收藏
    {
        type = @"1";
    }
    [SVProgressHUD show];
    [DKHTTPRequest sendDataWithShortUrl:@"favorites_user_co_goods"
                                  Param:[XXTool formatStringWithLanguage:[NSString stringWithFormat:@"userid=%@&passwd=%@&goodsid=%@&type=%@",[UserInfo shareUserInfo].userID,[UserInfo shareUserInfo].userPassword,_goodID,type]]
                             ImageArray:nil
                                TimeOut:10
                             Completion:^BOOL(NSMutableDictionary *serverDic, DKHTTPResponseType bufferType) {
                                 if ([[serverDic objectForKey:@"code"] intValue]==200)
                                 {
                                     if ([type isEqualToString:@"2"])
                                     {
                                         //collect.image = [UIImage imageNamed:@"收藏按钮_未点击"];
                                         
                                         [_testButton setTitle:NSLocalizedString(@"收藏展品", nil ) forState:UIControlStateNormal];
//                                         _barRightButton.title = NSLocalizedString(@"收藏展品", nil);
                                         useData.collection = @"0";
                                     }
                                     else if ([type isEqualToString:@"1"])
                                     {
                                         //collect.image = [UIImage imageNamed:@"收藏按钮_已点击"];
                                         
                                         [_testButton setTitle:NSLocalizedString(@"已收藏", nil ) forState:UIControlStateNormal];
//                                         _barRightButton.title = NSLocalizedString(@"已收藏", nil);
                                         useData.collection = @"1";
                                     }
                                     [SVProgressHUD showSuccessWithStatus:NSLocalizedString(@"操作成功", nil)];
                                 }
                                 return YES;
                             } IsBuffering:NO
                      IsNeedReplaceWrap:NO
                        IsUseUpLoadHead:NO];
}

#pragma mark posterButton
-(void)clickPosterButton
{
    [WebController pushWebControllerWithSourceVC:self requestString:useData.zs_hburl
                                         mapType:WebControllerDefault
                                        mapTitle:_exhibitorName
                                          signID:@""
     Company:@""];
}

-(void)clickLiuyanButton{
    if(UserInfo.shareUserInfo.isExhibitor){
        [LiuyanViewController pushVistorLiuyanDetailWithSourceVC:self apmentID:useData.exhibitorid Type:XVCExhi];
    }else{
        [LiuyanViewController pushVistorLiuyanDetailWithSourceVC:self apmentID:useData.exhibitorid Type:XVCVisitor];
    }
    
}

#pragma mark sendEmailAction
-(void)sendEmailAction
{
    // 邮件服务器
    MFMailComposeViewController *mailCompose = [[MFMailComposeViewController alloc] init];
    // 设置邮件代理
    [mailCompose setMailComposeDelegate:self];
    // 设置邮件主题
    //[mailCompose setSubject:@""];
    // 设置收件人
    [mailCompose setToRecipients:@[emailSend]];
    // 设置抄送人
    //[mailCompose setCcRecipients:@[@""]];
    // 设置密抄送
    //[mailCompose setBccRecipients:@[@""]];
    
    //设置邮件的正文内容
    //NSString *emailContent = @"我是邮件内容";
    // 是否为HTML格式
    //[mailCompose setMessageBody:emailContent isHTML:NO];
    // 如使用HTML格式，则为以下代码
    //	[mailCompose setMessageBody:@"<html><body><p>Hello</p><p>World！</p></body></html>" isHTML:YES];
    
    //添加附件
    
    //    UIImage *image = [UIImage imageNamed:@"image"];
    //    NSData *imageData = UIImagePNGRepresentation(image);
    //    [mailCompose addAttachmentData:imageData mimeType:@"" fileName:@"custom.png"];
    //    NSString *file = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];
    //    NSData *pdf = [NSData dataWithContentsOfFile:file];
    //    [mailCompose addAttachmentData:pdf mimeType:@"" fileName:@"7天精通IOS233333"];
    // 弹出邮件发送视图
    [self presentViewController:mailCompose animated:YES completion:nil];
}

#pragma mark MFMessageComposeViewControllerDelegate
- (void)mailComposeController:(MFMailComposeViewController *)controller
          didFinishWithResult:(MFMailComposeResult)result
                        error:(NSError *)error
{
    switch (result)
    {
        case MFMailComposeResultCancelled: // 用户取消编辑
            NSLog(@"Mail send canceled...");
            break;
        case MFMailComposeResultSaved: // 用户保存邮件
            NSLog(@"Mail saved...");
            break;
        case MFMailComposeResultSent: // 用户点击发送
            NSLog(@"Mail sent...");
            break;
        case MFMailComposeResultFailed: // 用户尝试保存或发送邮件失败
            NSLog(@"Mail send errored: %@...", [error localizedDescription]);
            break;
    }
    // 关闭邮件发送视图
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark api
+(void)pushProductDetailVCWithSourceVC:(UIViewController *)sourceVC goods_id:(NSString *)gid exhibitorName:(NSString *)exName
{
    XVCProductDetailShow *vc = [[XVCProductDetailShow alloc] init];
    vc.goodID = gid;
    vc.exhibitorName = exName;
    if (sourceVC)
    {
        [sourceVC.navigationController pushViewController:vc animated:YES];
    }
}

@end
